package com.caregiver.watch.business.user.model.vo;

import com.caregiver.watch.business.user.enums.WeekDay;
import com.caregiver.watch.business.user.model.po.UserReminder;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Set;

import static com.caregiver.watch.common.constant.NumberConstants.ONE_INTEGER;

/**
 * @Description: 用户提醒Vo
 * @Author 疆戟
 * @Date 2025/8/23 16:22
 * @Version 1.0
 */
@Data
@Schema(title = "用户提醒")
public class UserReminderVo {

    /**
     * 提醒ID
     */
    @Schema(description = "提醒ID")
    private Long id;

    /**
     * 用户ID
     */
    @Schema(description = "用户ID")
    private Long userId;

    /**
     * 提醒名称
     */
    @Schema(description = "提醒名称")
    private String reminderName;

    /**
     * 提醒内容
     */
    @Schema(description = "提醒内容")
    private String content;

    /**
     * 提醒开始时间
     */
    @Schema(description = "提醒开始时间")
    @JsonFormat(pattern = "HH:mm")
    private LocalTime startTime;

    /**
     * 提醒结束时间
     */
    @Schema(description = "提醒结束时间")
    @JsonFormat(pattern = "HH:mm")
    private LocalTime endTime;

    /**
     * 提醒间隔
     */
    @Schema(description = "提醒间隔")
    private Integer intervalValue;

    /**
     * 提醒间隔单位
     */
    @Schema(description = "提醒间隔单位")
    private String intervalUnit;

    /**
     * 重复周期
     */
    @Schema(description = "重复周期")
    private Set<WeekDay> repeatDays;

    /**
     * 是否启用
     */
    private Boolean isEnabled;



    public static UserReminderVo build(UserReminder reminder) {
        UserReminderVo reminderVo = new UserReminderVo();
        reminderVo.id = reminder.getId();
        reminderVo.userId = reminder.getUserId();
        reminderVo.reminderName = reminder.getReminderName();
        reminderVo.content = reminder.getContent();
        reminderVo.startTime = reminder.getStartTime();
        reminderVo.endTime = reminder.getEndTime();
        reminderVo.intervalValue = reminder.getIntervalValue();
        reminderVo.intervalUnit = reminder.getIntervalUnit();
        reminderVo.repeatDays = reminder.getRepeatDaysSet();
        reminderVo.isEnabled = ONE_INTEGER.equals(reminder.getIsEnabled());
        return reminderVo;
    }
}
